package com.vids.task;

import com.vids.mapper.VIIDServerMapper;
import com.vids.service.IBaseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;



/**
 * @author ly
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SyncRegisterTask {

    private final IBaseService baseService;
    private final VIIDServerMapper viidServerMapper;

    @Scheduled(fixedRate = 90000, initialDelay = 10000)
    public void syncStatus() {
        updateServerStatus();
    }

    private void updateServerStatus() {
        log.info(">>>>>>>>> 更新VIIDServer 状态 >>>>>>>>>>>   间隔时间为三秒");
        // 刷离线
        baseService.updateStatusByDate();
        // 根据status 表 刷新状态
        viidServerMapper.updateIsOnlineStatuts();
    }

}
